package com.hljcert.data.service.system.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.stp.StpUtil;
import com.hljcert.data.service.common.result.Result;
import com.hljcert.data.service.system.dto.LoginDTO;
import com.hljcert.data.service.system.service.AuthService;
import com.hljcert.data.service.system.vo.LoginVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/auth")
public class AuthController {

    @Autowired
    private AuthService authService;

    @SaIgnore
    @ApiOperation(value = "登录系统", httpMethod = "POST")
    @PostMapping("/login")
    public Result<LoginVO> doLogin(@RequestBody @Valid LoginDTO dto){
        return this.authService.login(dto);
    }

    @GetMapping("isLogin")
    public Result isLogin() {
        return Result.OK("是否登录：" + StpUtil.isLogin());
    }

}
